import request from '@/utils/request'

export function listType(data) {
  return request({
    url: 'gl/auxiliaryType/getAll',
    method: 'post',
    data
  })
}

export function delType(data) {
  return request({
    url: 'gl/auxiliaryType/deleteById',
    method: 'post',
    data
  })
}

export function updateIsDisableById(data) {
  return request({
    url: 'gl/auxiliaryType/updateIsDisableById',
    method: 'post',
    data
  })
}

export function saveType(data) {
  return request({
    url: 'gl/auxiliaryType/update',
    method: 'post',
    data
  })
}

export function nextBdCode(data) {
  return request({
    url: 'gl/auxiliaryType/nextBdCode',
    method: 'post',
    data
  })
}

export function getAuxiliary(data) {
  return request({
    url: 'gl/auxiliaryType/getBdDataAll',
    method: 'post',
    data
  })
}

export function saveAuxiliary(data) {
  return request({
    url: 'gl/auxiliaryType/saveBdData',
    method: 'post',
    data
  })
}

export function delAuxiliary(data) {
  return request({
    url: 'gl/auxiliaryType/deleteBdDataById',
    method: 'post',
    data
  })
}

export function importAuxiliary(data) {
  return request({
    url: 'gl/auxiliaryType/importBdData',
    method: 'post',
    timeout: 10000,
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

export function exportAuxiliary(data) {
  const exportUrl = 'gl/auxiliaryType/exportBdData'
  var temp = document.createElement('form')
  temp.action = exportUrl
  temp.method = 'POST'
  temp.style.display = 'none'
  for (var x in data) {
    var opt = document.createElement('textarea')
    opt.name = x
    opt.value = data[x]
    temp.appendChild(opt)
  }
  document.body.appendChild(temp)
  temp.submit()
  return temp
}
